<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>修改客户联系人信息</title>
	<base href="<%=basePath%>"/>
	<%@ include file="../../cuv_include.jsp"%>
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	</style>
<script language="JavaScript" type="text/javascript" src="<%=basePath%>js/my97/WdatePicker.js" defer="defer"></script>
<script type="text/javascript">
  $(document).ready(function(){
      var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
      $("#itemForm").submit(function(){
    	  $("#btn_insert").attr("disabled","disabled");
          $(this).ajaxSubmit(options);
          return false;
      });      
  });
  
  function beforeSubmit() {
	  if(isEmpty($("#name").val())) { $('#error_label').text("错误信息：姓名不能为空！"); 
	  	$("#p_error").show();
	  	$("#btn_insert").removeAttr("disabled");
    	return false; }
	  if(isEmpty($("#company").val())) { $('#error_label').text("错误信息：公司名称不能为空！"); 
	  	$("#p_error").show();
	  	$("#btn_insert").removeAttr("disabled");
  		return false; }

      return true;
  }

    function process(responseJson) {
    	$("#btn_insert").removeAttr("disabled");
      if(responseJson.code == 0) {
          $('#error_label').text("错误信息：" + responseJson.message);
          $("#p_error").show();
          return;
      }
      var qs = $("#qs").val();
      location.href = "<%=basePath%>req/customercontacts/list.do?" + qs;
    }  
</script>
</head>
<body>
  <div>
    <fieldset>
      <legend>修改客户联系人：</legend>
      <form id="itemForm" method="post" action="req/customercontacts/update.do">
        <input id="qs" name="qs" type="hidden" value="${qs}"/>
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
          <tr>
            <td><label for="name">姓名：</label></td>
            <td>
            	<input type="text" name="name" id="name" value="${item.name }"/>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><input type="hidden" name="id" id="id" value="${item.id }"/></td>
          </tr> 
          <tr>
            <td valign="top"><label for="province">省份：</label></td>
            <td valign="top">
            	<select id="province" name="province" style="width:120px;">
                   <c:forEach items="${provinces}" var="pro" varStatus="status">
                   		<option value="${pro.key }" <c:if test="${pro.key == item.province }">selected ="true"</c:if>>${pro.value }</option>
                   </c:forEach>
              	</select>   
              	<font color="red">&nbsp;*&nbsp;&nbsp;</font>   
            </td>
          </tr>  
          <tr>
            <td valign="top"><label for="company">公司名称：</label></td>
            <td valign="top"><input type="text" name="company" id="company" value="${item.company }"/>
            <font color="red">&nbsp;*&nbsp;&nbsp;</font></td>
          </tr>        
          <tr>
            <td valign="top"><label for="post">职位：</label></td>
            <td valign="top"><input type="text" name="post" id="post" value="${item.post }"/>
          </tr>   
          <tr>
            <td valign="top"><label for="phone">固定电话：</label></td>
            <td valign="top"><input type="text" name="phone" id="phone" value="${item.phone }"/></td>
          </tr>
          <tr>
          	<td><label for="mobile">手机号码：</label></td>
          	<td><input type="text" name="mobile" id="mobile" value="${item.mobile }"/></td>
          </tr>  
          <tr>
          	<td><label for="email">邮箱地址：</label></td>
          	<td><input type="text" name="email" id="email" value="${item.email }"/></td>
          </tr>
          <tr>
          	<td><label for="qq">QQ号码：</label></td>
          	<td><input type="text" name="qq" id="qq" value="${item.qq }"/></td>
          </tr>
          <tr>
          	<td><label for="remark">备注信息：</label></td>
          	<td><textarea rows="5" cols="30" name="remark" id="remark"><c:out value="${item.remark }"></c:out></textarea></td>
          </tr>            
          <tr>
            <td></td>
            <td>
            	<input type="submit" id="btn_insert" value="提交" style="width:80px;" />
            	<input type="button" id="btn_back" value="返回" onclick="history.back();" style="width:80px;" />
            </td>
          </tr>
        </table>
      </form>
    </fieldset>
  </div>
</body>
</html>